<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2023/5/17
  Time: 16:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!doctype html>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="hplus/static/ztree/css/zTreeStyle/zTreeStyle.css">
    <script type="text/javascript" src="hplus/static/jquery-3.6.3.min.js"></script>
    <script type="text/javascript" src="hplus/static/ztree/js/jquery.ztree.core.min.js"></script>
    <script type="text/javascript" src="hplus/static/ztree/js/jquery.ztree.excheck.js"></script>

</HEAD>
<BODY>
<div>
    <div id="treeDemo" class="ztree"></div>
    <input type="button" value="获取选中的节点" onclick="getCheckedNodes();">
</div>
</BODY>
<script src="hplus/js/plugins/layer/layer.min.js" type="text/javascript"></script>
<script src="hplus/js/sofwin.js"></script>
<SCRIPT LANGUAGE="JavaScript">
    var zTreeObj;
    // zTree 的参数配置，深入使用请参考 API 文档（setting 配置详解）
    // 对树进行配置的  能不有复选框
    function zTreeOnCheck(event, treeId, treeNode) {
        alert(treeNode.tId + ", " + treeNode.name + "," + treeNode.checked);
    };
    var setting = {
        data:{
            simpleData:{
                enable: true,// 简单格式的json数据
                idKey: 'id',
                pIdKey:'parentId',
                rootPId: 0   // 第一层节点的PID的值
            }
        },
        check:{
            enable: true
        },
        callback: {
            // 当单选框或复选框被勾选或取消勾选时进行的回调
            onCheck: zTreeOnCheck
        }
    };
    // zTree 的数据属性，深入使用请参考 API 文档（zTreeNode 节点数据详解）
    // 数组就是我们的节点数据
    //
    var zNodes = [
        {name:"test1", open:true, children:[
                {name:"test1_1"}, {name:"test1_2"}]},
        {name:"test2", open:false, children:[
                {name:"test2_1"}, {name:"test2_2"}]}
    ];
    var zNodes1;
    $.operator.get('resource',function(ret){
        zNodes1=ret.data;


    })
    zTreeObj = $.fn.zTree.init($("#treeDemo"), setting, zNodes1);
    function getCheckedNodes(){
        // 来获取当前选中的所有节点
    var checkedNodes = zTreeObj.getCheckedNodes(true);
    console.info(checkedNodes)
    }
</SCRIPT>
</HTML>
